fix: handle recursive watcher ignore paths correctly#13756
Open
ManManavadaria wants to merge 1 commit intodocker:mainfrom
Open
fix: handle recursive watcher ignore paths correctly#13756ManManavadaria wants to merge 1 commit intodocker:mainfrom
ManManavadaria wants to merge 1 commit intodocker:mainfrom
Conversation
Signed-off-by: ManManavadaria <manmanavadaria@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to fix Docker Compose watch startup failures when an ignored path is unreadable by pushing ignore handling down into the watcher layer. In the codebase, that primarily affects how pkg/compose constructs file watchers and how pkg/watch traverses directories on different platforms.
Changes:
- Added an ignore matcher parameter to the watcher API and threaded it through Compose watch setup.
- Updated the naive watcher to skip ignored directories during recursive traversal and to suppress permission errors for ignored paths during startup walks.
- Adjusted Darwin watcher and test fixture construction to use the new watcher signature.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/watch/watcher_naive.go |
Adds ignore-aware traversal and permission handling to the non-fsevents watcher implementation. |
pkg/watch/watcher_darwin.go |
Updates the Darwin watcher constructor signature to match the new watcher API. |
pkg/watch/notify_test.go |
Updates test fixture setup to call NewWatcher with an ignore matcher. |
pkg/watch/notify.go |
Extends the exported watcher constructor to accept an ignore matcher. |
pkg/compose/watch.go |
Builds ignore matchers from watch triggers and passes them into watcher creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+277
to
+285
| matches, err := d.ignore.MatchesEntireDir(path) | ||
| if err != nil { | ||
| logrus.Debugf("error checking ignored directory %q: %v", path, err) | ||
| return false | ||
| } | ||
| if matches { | ||
| return true | ||
| } | ||
| matches, err = d.ignore.Matches(path) |
Comment on lines
+117
to
+120
| if os.IsPermission(err) && d.shouldIgnore(path) { | ||
| logrus.Debugf("Ignoring path: %s", path) | ||
| return nil | ||
| } |
| } | ||
|
|
||
| watcher, err := watch.NewWatcher(paths) | ||
| watcher, err := watch.NewWatcher(paths, watch.NewCompositeMatcher(ignoreMatchers...)) |
| } | ||
|
|
||
| func newWatcher(paths []string) (Notify, error) { | ||
| func newWatcher(paths []string, _ PathMatcher) (Notify, error) { |
Comment on lines
+117
to
+119
| if os.IsPermission(err) && d.shouldIgnore(path) { | ||
| logrus.Debugf("Ignoring path: %s", path) | ||
| return nil |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Applied ignore rules at the watcher layer and updated recursive traversal to skip ignored files/directories, ensuring permission errors from paths in the ignore list do not fail watch.
Related issue
fixes #13750
(not mandatory) A picture of a cute animal, if possible in relation to what you did